package com.znyj.servlet.vo;

import java.util.List;

/**
 * Created by gaoliwei02 on 17/6/26.
 */
public class Page<E> {
    private int currentPageNumber;
    private int total; //总共的行数
    private int pageSize; // 一页所能容纳的最大行数
    private List<E> rows; // 当前页包含的行数据

    public int getCurrentPageNumber() {
        return currentPageNumber;
    }

    public void setCurrentPageNumber(int currentPageNumber) {
        this.currentPageNumber = currentPageNumber;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public List<E> getRows() {
        return rows;
    }

    public void setRows(List<E> rows) {
        this.rows = rows;
    }

    public static <E> Page<E> createPage(int currentPageNumber, int pageSize, List<E> elements, int totalCount) {
        Page<E> page = new Page<>();
        page.setCurrentPageNumber(currentPageNumber);
        page.setPageSize(pageSize);
        page.setRows(elements);
        page.setTotal(totalCount);
        return page;
    }
}

